Skip to content

Latest commit

 

History

History
46 lines (37 loc) · 1.46 KB

Coupling Between Test Methods.rst

File metadata and controls

46 lines (37 loc) · 1.46 KB

Coupling Between Test Methods ^^^^^ Definition:

  • Test methods (and all tests in general) must be perfectly isolated from each other. This means that changing one test must not affect any others.

Code Example:

public final class MetricsTest {
  private File temp;
  private Folder folder;
  @Before
  public void prepare() {
    this.temp = Files.createTempDirectory("test");
    this.folder = new DiscFolder(this.temp);
    this.folder.save("first.txt", "Hello, world!");
    this.folder.save("second.txt", "Goodbye!");
  }
  @After
  public void clean() {
    FileUtils.deleteDirectory(this.temp);
  }
  @Test
  public void calculatesTotalSize() {
    assertEquals(22, new Metrics(this.folder).size());
  }
  @Test
  public void countsWordsInFiles() {
    assertEquals(4, new Metrics(this.folder).wc());
  }
}

References:

Quality attributes

  • file-code;1em - Code Example
  • comment-discussion;1em - Cause and Effect
  • graph;1em - Frequency
  • sync;1em - Refactoring